#include "CCore.hpp"

#include "Datas.hpp"
#include "CPlayer.hpp"
#include "CField.hpp"

#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cassert>

////////////////////////////////////////////////////////////////
// Annonymous
//
namespace
{
	class MinimalExtractor
	{
		uint c;
		bool first;
	public:
		void operator ()(CMobs* mobs)
		{
			if(first) c = mobs->size();
			else c = std::min(c, (uint)mobs->size());
		}
		
		operator int()
		{
			return c;
		}
	};
}

////////////////////////////////////////////////////////////////
// CCore
//
CCore::CCore()
{
}

CCore::~CCore()
{
}

/**
* @brief Check the state of game
*
* @return The state of game
* @retval 0 game will continue to run.
* @retval -1 Game is over
*/
int CCore::update()
{
	MinimalExtractor me;
	Players.foreach<CMobs>(me);
	if(me == 0)
		return -1;
	return 0;
}

